<?php
header("Content-type: application/json");
$con = mysql_connect("localhost", "root", "");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
} else {
   mysql_select_db("dutoan_db", $con);
 	$c1 = mysql_real_escape_string($_POST['models'][0]['c1'], $con);
	$c2 = mysql_real_escape_string($_POST['models'][0]['c2'], $con);
	$sql = sprintf("INSERT INTO thetest(c1, c2) VALUES('%s','%s')", $c1, $c2);;
   $rs = mysql_query($sql);
 
   if ($rs) {
    echo json_encode($rs);
 }
  else {
        header("HTTP/1.1 500 Internal Server Error");
        echo "Failed on insert: " . $_POST['models'][0]['Column1'];
  }
mysql_close($con);
}
?> 